<template>
  <div>
    <div class="footer_wrap">
      <!-- <a href="#/find">发现音乐</a>
      <a href="#/my">我的音乐</a>
      <a href="#/part">朋友</a> -->

      <!-- <router-link to="/find">发现音乐</router-link>
      <router-link to="/my">我的音乐</router-link>

      <router-link to="/part?name=高仙芝&age=46">朋友-query传参</router-link>
      <router-link to="/part/郭子仪/72">朋友-params传参</router-link> -->

      <span @click="$router.push('/find')">发现音乐</span>
      <span @click="goto('/my', 'My')">我的音乐</span>
      <span @click="gotoPartQuery('/part', 'Part')">朋友-query传参</span>
      <span @click="gotoPartParams('/part', 'Part')">朋友-params传参</span>
    </div>
    <div class="top">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    goto (path, name) {
      this.$router
        .push({
          path
        })
        .catch(e => e) //捕获了错误, 但什么都不处理, 直接返回错误对象
    },
    gotoPartQuery (path, name) {
      this.$router
        .push({
          path,
          query: {
            name: '张三',
            age: 18
          }
        })
        .catch(e => e)
    },
    gotoPartParams (path, name) {
      this.$router
        .push({
          name,
          params: {
            name: '李四',
            age: 12
          }
        })
        .catch(e => e)
    }
  }
}
</script>

<style scoped>
.footer_wrap {
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  width: 100%;
  text-align: center;
  background-color: #333;
  color: #ccc;
}
.footer_wrap a,
span {
  flex: 1;
  text-decoration: none;
  padding: 20px 0;
  line-height: 20px;
  background-color: #333;
  color: #ccc;
  border: 1px solid black;
}
.footer_wrap a:hover,
span:hover {
  background-color: #555;
}
.top {
  padding-top: 62px;
}
.router-link-active {
  background-color: black !important;
}
</style>
